import _ from 'lodash'
import request from '@/utils/request'
import { message } from '@/utils/resetMessage'
import Vue from 'vue'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'

Vue.use(VXETable)
export default {
  install(Vue) {
    Object.defineProperty(Vue.prototype, '$_', { value: _ })
    Object.defineProperty(Vue.prototype, '$request', { value: request })
    Object.defineProperty(Vue.prototype, '$message', { value: message })

    Vue.prototype.$validate = async(app, formName = 'form') => {
      return new Promise(resolve => {
        app.$refs[formName].validate(valid => {
          if (valid) {
            resolve(valid)
          }
        })
      })
    }
  }
}
